/*
day470 
2020.12.10 
*/

#include<iostream>
#include<queue>
#include<vector>
using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    bool isEvenOddTree(TreeNode* root) {
        queue<TreeNode *> que;
        TreeNode *tem=nullptr;
        int pre;
        que.push(root);
        int high=0;
        while(!que.empty())
        {
        	int size=que.size();
        	for(int i=0;i<size;++i)
        	{
        		tem=que.front();
        		que.pop();
        		if(high%2==0)
        		{
        			if((tem->val%2==0) || (i>0 && pre>=tem->val))
        			{
        				return false;
					}
				}
				else
				{
					if((tem->val%2==1) || (i>0 && pre<=tem->val))
        			{
        				return false;
					}
				}
                pre=tem->val;
                if(tem->left) que.push(tem->left);
                if(tem->right) que.push(tem->right);
			}
			
			high++;
		}
		
		return true;
    }
};

int main()
{
	return 0;
 } 
